/**
 * APIGoods
 * Created by yanjd on 2017/9/22.
 */

import {type} from '../type'

let api = {}


/**
 * 创建金币商品
 * @param state
 * @param commit
 * @param rootState
 * @param params = {roleRank, gameId, goodsType, isAxm, qq, serviceProviderId, regionId, serverId, tel, price, unitNum, deliveryNum}
 * roleRank 角色等级 unitNum 出售数量（单件） deliveryNum 发布件数
 */
api[type.createCoinGoods] = ({state, commit, rootState}, params) => {
  return rootState.axios.post(rootState.CONSTANTS.APIGoods + 'sycurrencygoods/createsycurrencygoods', params).then(res => {
    return res.data
  })
}

/**
 * 创建账号商品
 * @param state
 * @param commit
 * @param rootState
 * @param params = {description, gameAccount, gameId, gamePwd, gameRoleName, goodsImgEOList, goodsType, isAxm, isRobotCapture, mainGid, propertyEOLis: [{attributeId, attributeName, attributeVal, mainGamePropertyId]}, qq, regionId, serverId, serviceProviderId, supplyServerName, tel, totalAmount}
 *
 */
api[type.createAccountGoods] = ({state, commit, rootState}, params) => {
  return rootState.axios.post(rootState.CONSTANTS.APIGoods + 'goods/account/createaccountgoods', params).then(res => {
    return res.data
  })
}


/**
 * 获取金币商品详情
 * @param state
 * @param commit
 * @param rootState
 * @param params = {goodsId}
 */
api[type.getCoinGoodsDetail] = ({state, commit, rootState}, params) => {
  return rootState.axios.get(rootState.CONSTANTS.APIGoods + 'sycurrencygoods/sycurrencydetail', {params}).then(res => {
    return res.data
  })
}

/**
 * 获取商品详情
 * @param state
 * @param commit
 * @param rootState
 * @param params = {bizOfferId}
 */
api['MG_GOODS_DETAIL'] = ({state, commit, rootState}, params) => {
  return rootState.axios.post(rootState.CONSTANTS.APIMGCoin+ 'goods/getGoodsDetail', params).then(res => {
    return res.data.data
  })
}

export default {
  ...api
}
